﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Client_test
{
    public partial class TestPageMain : Form
    {
        public TestPageMain()
        {
            InitializeComponent();
            /*
            disconnectBTN.Enabled = false;
            downloadBTN.Enabled = false;
            sendBTN.Enabled = false;
            chatBTN.Enabled = false;
            hiBTN.Enabled = false;
            */
        }

        private void connectBTN_Click(object sender, EventArgs e)
        {
            ClientAPI.Model.Instance.Connect();
        }

        private void disconnectBTN_Click(object sender, EventArgs e)
        {
            ClientAPI.Model.Instance.LogOut();
        }

        private void loginBTN_Click(object sender, EventArgs e)
        {
            ClientAPI.Model.Instance.Connect();
            while (!ClientAPI.Model.Instance.IsConnected()) ;
            Login(ClientAPI.Model.Instance.Login(userTXT.Text, passTXT.Text));
        }

        private void downloadBTN_Click(object sender, EventArgs e)
        {
            ClientAPI.Model.Instance.Download("space.jpg");
        }

        private void chatBTN_Click(object sender, EventArgs e)
        {
            ChatWindow chatWindow = new ChatWindow();
            chatWindow.Show();

            ClientAPI.Model.Instance.ChatMessageReceived();
        }

        private void Login(bool loggedIn)
        {
            /*
            disconnectBTN.Enabled = loggedIn;
            downloadBTN.Enabled = loggedIn;
            sendBTN.Enabled = loggedIn;
            chatBTN.Enabled = loggedIn;
            hiBTN.Enabled = loggedIn;
            connectBTN.Enabled = !loggedIn;
            */
        }

        private void createBTN_Click(object sender, EventArgs e)
        {
            ClientAPI.Model.Instance.CreateUser(userBOX.Text, "Bill", "Blanko", passBOX.Text, "1800-shutyourface", "bill@whocares.com");
        }
    }
}
